<template>
  <swiper :options="swiperOptions" v-if="banner.length > 0" class="banner">
    <swiper-slide v-for="value in banner" :key='value.bannerId' class="item">
      <a :href="value.url" class="">
        <img v-lazy="value.pic" alt="">
      </a>
    </swiper-slide>
    <div class="swiper-pagination" slot="pagination"></div>
  </swiper>
</template>

<script>
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'

export default {
  name: 'Banner',
  data () {
    return {
      swiperOptions: {
        loop: true,
        autoplay: {
          delay: 1000,
          stopOnLastSlide: false,
          disableOnInteraction: false
        },
        pagination: {
          el: '.swiper-pagination'
        },
        observer: true,
        observeParents: true,
        observeSlideChildren: true
      }
    }
  },
  props: {
    banner: {
      type: Array,
      default: () => [],
      required: true
    }
  },
  created () {
    // console.log(this.banner)
  },
  components: {
    swiper,
    swiperSlide
  },
  methods: {}
}
</script>

<style scoped lang = 'scss'>
  .banner{
    .item{
      img{
        width: 100%;
        height: 300px;
      }
    }
  }
</style>
<style lang = 'scss'>
  .banner{
    .swiper-pagination-bullet{
      width: 16px;
      height: 16px;
      background: white;
      opacity: 1;
    }
    .swiper-pagination-bullet-active{
      background: violet;
    }
  }
</style>
